package org.example;

import org.junit.Test;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

public class InvokeTest {
    @Test
    public void getXMLBeanByInvoke() throws Exception {
        MyClassPathXmlApplicationContext context = new MyClassPathXmlApplicationContext("beans.xml");
        Class<?> moAttack = context.getBean("moAttack");
        Constructor<?> constructor = moAttack.getDeclaredConstructor(GeLi.class);
        constructor.setAccessible(true);
        MoAttack instance = (MoAttack) constructor.newInstance(new LiuDeHua());
        Method method = moAttack.getMethod("cityGateAsk");
        method.invoke(instance);
    }
}
